﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="文件上传带进度.aspx.cs" Inherits="Study.文件上传带进度" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#submit").click(function () {
                $("#form1").submit();                
            });           
        });

        function RequestProgress() {
            $.post("Ajax/RequestProgressAsyncHandler.ashx", function (data, status) {
                if (status == "success") {
                    $("#progressBar").html(data + "%");
                    data = parseInt(data);
                    //如果进度不是 100,则重新请求
                    if (data != 100) {
                        RequestProgress();
                    }
                }
            });
        }

        
    </script>
</head>
<body>
    <form id="form1" runat="server" onsubmit="RequestProgress();" action="Ajax/UploadFileHandler.ashx" method="post" target = "frameFileUpload" enctype="multipart/form-data">
    <div>
        <input type="file" id="fileUpload" name="fileUpload" />
        <div id="progressBar" style="font-size: 1em;"></div>
        <iframe  id="frameFileUpload" name="frameFileUpload" style="display:none;"></iframe>
        <input type="submit" value="上传" id = "submit"/>
    </div>
    </form>
   
</body>
</html>
